// Elipse.cpp: implementation of the Elipse class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "sisgraf03.h"
#include "Elipse.h"
#include <math.h>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Elipse::Elipse(double xc, double yc, double rx, double ry,int c, bool rellenado)
{
	Pc = new Puntos(xc,yc);
	radiox = rx;
	radioy = ry;
	relleno = rellenado;
	color = c;

}

Elipse::~Elipse()
{
	delete Pc;
}

void Elipse::Transformar(Matriz m)
{
	radiox *= m.Elemento(1,1);
	radioy *= m.Elemento(2,2);
	Matriz p1 = Vector(Pc);
	*Pc = Punto(m*p1);
}

void Elipse::Escalar(double ex, double ey)
{
	Matriz m = M_Escalado(ex, ey);
	Transformar(m);
}

void Elipse::Dibujar(Matriz m,int *cVP, CDC* pDC)
{
	Transformar(m);
	redondearPtos();

	elipse(color,Pc->obtenerX(),Pc->obtenerY(),radiox,radioy,relleno,cVP,pDC);


}

void Elipse::redondearPtos()
{
	double p[2];
	p[0] = floor (Pc->obtenerX() + 0.5);
	p[1] = floor (Pc->obtenerY() + 0.5);	
	Pc->modificarCoord(p);
	radiox = floor(radiox + 0.5);
	radioy = floor(radioy + 0.5);
}
